<%@page import="classes.Url"%>
<%@page import="models.Course"%>
<%@page import="dao.CourseDao"%>
<%@page import="models.Category"%>
<%@page import="java.util.List"%>
<%@page import="dao.CategoryDao"%>
<%@page import="classes.HibernateUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div id="shadow"></div>
<div id="dialog-confirm">
    <text id="context"><text>
</div>   
<div class="catalog">
    <a href="${url}Category"><h2>${uq_course_catalog}</h2></a>
    <%
        HibernateUtil hu = new HibernateUtil();
        CategoryDao ed = new CategoryDao(hu.openSession());
        CourseDao cd = new CourseDao(hu.openSession());
       
        List<Category> categoryList = ed.findAll();        
        request.setAttribute("categories", categoryList);
        Url.setHistory(request);
    %>    
    <ul>        
        <c:forEach items="${categories}" var="categories">          
            <c:set var="catid" value="${categories.id}" />            
            <%            
            List<Course> courseList = cd.findAllByCategory(Long.parseLong(pageContext.getAttribute("catid").toString()), 999);
            request.setAttribute("courses", courseList);            
            int courseSize = courseList.size();            
            if (courseList.size() > 0) { 
            %>
            <li class="expand">            
                ${categories.name}
                <ul>
                    <c:forEach items="${courses}" var="courses">
                        <li>
                            <a href="${url}Course?courseid=${courses.id}">${courses.name}</a>
                        </li>
                    </c:forEach>
                </ul>
            </li>   
            <% } %>
        </c:forEach>                
    </ul>
</div>
<footer>
    <div>
        <a href="${url}Page?p=contact">Contact</a> | 
        <a href="${url}Page?p=privacy_policy">Privacy Policy</a> | 
        <a href="${url}Page?p=disclaimer">Disclaimer</a> | 
        <a href="">Sitemap</a> | 
        <a href="${url}">${uq_all_rights_reserved}</a>
    </div>
    <div>
        ${website} &copy Copyright 2013
    </div>
</footer>
